
if not posix_option
	subdir_done()
endif
libc_sources += files(
	'generic/arpa-inet.cpp',
	'generic/dirent.cpp',
	'generic/dlfcn.cpp',
	'generic/fcntl.cpp',
	'generic/ftw.cpp',
	'generic/grp.cpp',
	'generic/langinfo.cpp',
	'generic/libgen.cpp',
	'generic/lookup.cpp',
	'generic/netdb.cpp',
	'generic/net-if.cpp',
	'generic/poll.cpp',
	'generic/posix_ctype.cpp',
	'generic/posix-file-io.cpp',
	'generic/posix_locale.cpp',
	'generic/posix_signal.cpp',
	'generic/posix_stdio.cpp',
	'generic/posix_stdlib.cpp',
	'generic/posix_string.cpp',
	'generic/posix_time.cpp',
	'generic/pthread.cpp',
	'generic/pwd.cpp',
	'generic/resolv_conf.cpp',
	'generic/sched.cpp',
	'generic/spawn.cpp',
	'generic/strings.cpp',
	'generic/services.cpp',
	'generic/sys-file.cpp',
	'generic/syslog.cpp',
	'generic/sys-mman.cpp',
	'generic/sys-resource.cpp',
	'generic/sys-select.cpp',
	'generic/sys-shm.cpp',
	'generic/sys-socket.cpp',
	'generic/sys-stat.cpp',
	'generic/sys-statvfs.cpp',
	'generic/sys-times.cpp',
	'generic/sys-time.cpp',
	'generic/sys-uio.cpp',
	'generic/sys-utsname.cpp',
	'generic/sys-wait.cpp',
	'generic/termios.cpp',
	'generic/unistd.cpp',
	'generic/utime.cpp',
	'generic/ucontext.cpp',
	'generic/semaphore.cpp',
	'generic/search.cpp',
	'generic/sys-msg.cpp',
	'generic/sys-sem.cpp',
	'generic/sys-ipc.cpp',
	'generic/time.cpp',
	'generic/wordexp.cpp',
	'generic/mqueue.cpp'
)

if not headers_only
	libc_sublibs += static_library('musl-generic-regex',
		'musl-generic-regex/fnmatch.c',
		'musl-generic-regex/glob.c',
		'musl-generic-regex/regcomp.c',
		'musl-generic-regex/regerror.c',
		'musl-generic-regex/regexec.c',
		'musl-generic-regex/tre-mem.c',
		pic: true,
		include_directories: libc_include_dirs,
		dependencies: libc_deps,
		c_args: ['-Wno-unused', '-Wno-implicit', '-Wno-parentheses', '-Wno-sign-compare', '-Wno-attributes', '-Wno-unknown-pragmas', '-Wno-implicit-fallthrough', '-Wno-unused-parameter']
	)
endif

if not no_headers
	install_headers(
		'include/byteswap.h',
		'include/dirent.h',
		'include/dlfcn.h',
		'include/fcntl.h',
		'include/fnmatch.h',
		'include/ftw.h',
		'include/glob.h',
		'include/grp.h',
		'include/langinfo.h',
		'include/libgen.h',
		'include/netdb.h',
		'include/nl_types.h',
		'include/pthread.h',
		'include/pwd.h',
		'include/poll.h',
		'include/regex.h',
		'include/sched.h',
		'include/search.h',
		'include/spawn.h',
		'include/strings.h',
		'include/syslog.h',
		'include/termios.h',
		'include/unistd.h',
		'include/utime.h',
		'include/ucontext.h',
		'include/wordexp.h',
		'include/semaphore.h',
		'include/mqueue.h',
	)
	install_headers(
		'include/arpa/inet.h',
		subdir: 'arpa'
	)
	install_headers(
		'include/net/if.h',
		'include/net/if_arp.h',
		subdir: 'net'
	)
	install_headers(
		'include/netinet/in.h',
		'include/netinet/ip.h',
		'include/netinet/tcp.h',
		'include/netinet/icmp6.h',
		'include/netinet/if_ether.h',
		'include/netinet/udp.h',
		'include/netinet/ip6.h',
		'include/netinet/ip_icmp.h',
		subdir: 'netinet'
	)
	install_headers(
		'include/sys/file.h',
		'include/sys/ipc.h',
		'include/sys/mman.h',
		'include/sys/msg.h',
		'include/sys/param.h',
		'include/sys/poll.h',
		'include/sys/resource.h',
		'include/sys/select.h',
		'include/sys/sem.h',
		'include/sys/shm.h',
		'include/sys/socket.h',
		'include/sys/stat.h',
		'include/sys/statvfs.h',
		'include/sys/termios.h',
		'include/sys/time.h',
		'include/sys/times.h',
		'include/sys/ttydefaults.h',
		'include/sys/types.h',
		'include/sys/uio.h',
		'include/sys/un.h',
		'include/sys/utsname.h',
		'include/sys/wait.h',
		'include/sys/syslog.h',
		subdir: 'sys'
	)
	install_headers(
		'include/bits/posix/id_t.h',
		'include/bits/posix/in_addr_t.h',
		'include/bits/posix/in_port_t.h',
		'include/bits/posix/iovec.h',
		'include/bits/posix/locale_t.h',
		'include/bits/posix/posix_ctype.h',
		'include/bits/posix/posix_locale.h',
		'include/bits/posix/posix_signal.h',
		'include/bits/posix/posix_stdio.h',
		'include/bits/posix/posix_stdlib.h',
		'include/bits/posix/posix_string.h',
		'include/bits/posix/posix_time.h',
		'include/bits/posix/posix_wctype.h',
		'include/bits/posix/stat.h',
		'include/bits/posix/timeval.h',
		'include/bits/posix/fd_set.h',
		'include/bits/posix/pthread_t.h',
		'include/bits/posix/timer_t.h',
		subdir: 'bits/posix'
	)
endif

